package cn.xaut.数组;

import java.util.Arrays;

public class demo80 {

    public int removeDuplicates(int[] nums) {

        int len = nums.length;
        if (len <= 2)
            return len;

        int slow = 1;
        for (int fast = 2; fast < len; fast++) {
            if (nums[slow - 1] != nums[fast]) {
                slow++;
                nums[slow] = nums[fast];
            }
        }

        System.out.println(Arrays.toString(nums));
        return slow + 1;
    }

    public static void main(String[] args) {

        System.out.println(new demo80().removeDuplicates(new int[]{1, 1, 1, 2, 2, 3}));//5
        System.out.println(new demo80().removeDuplicates(new int[]{0, 0, 1, 1, 1, 1, 2, 3, 3}));//7
    }
}
